import org.apache.spark.{SparkConf, SparkContext}  
import org.apache.spark.rdd.RDD  
  
object RDDPartitions {  
  def main(args: Array[String]): Unit = {  
    val conf = new SparkConf().setAppName("RDD Partitions").setMaster("local[*]")  
    val sc = new SparkContext(conf)  
  
    val rdd = sc.parallelize(Seq("apple", "banana", "orange", "pear", "watermelon", "grape", "pineapple"))  
  
    val partitionedRDD: Map[Boolean, RDD[String]] = rdd.partitionBy(new org.apache.spark.Partitioner {  
      override def numPartitions: Int = 2  
  
      override def getPartition(key: Any): Int = {  
        key.toString.length() <= 5 ? 0 : 1  
      }  
  
      override def equals(other: Any): Boolean = other match {  
        case x: org.apache.spark.Partitioner